package com.probox.common.entity.service.centre.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.probox.common.entity.domain.centre.ProductOperationDetail;
import com.probox.common.entity.mapper.centre.CentreProductOperationDetailMapper;
import com.probox.common.entity.service.centre.IProductOperationDetailService;
import com.probox.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * 用户行为日志Service业务层处理
 *
 *
 * @date 2021-06-08
 */
@Service
@Transactional
public class CentreProductOperationDetailServiceImpl extends ServiceImpl<CentreProductOperationDetailMapper, ProductOperationDetail> implements IProductOperationDetailService {
    @Autowired
    private CentreProductOperationDetailMapper centreProductOperationDetailMapper;


    /**
     * 查询用户行为日志
     *
     * @param detailUid 用户行为日志ID
     * @return 用户行为日志
     */
    @Override
    public ProductOperationDetail selectProductOperationDetailById(Long detailUid) {
        return this.getById(detailUid);
    }

    /**
     * 查询用户行为日志列表
     *
     * @param productOperationDetail 用户行为日志
     * @return 用户行为日志
     */
    @Override
    public List<ProductOperationDetail> queryList(ProductOperationDetail productOperationDetail) {
        QueryWrapper<ProductOperationDetail> queryWrapper = Wrappers.query();
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getDetailUid())) && productOperationDetail.getDetailUid() != null) {
            queryWrapper.eq("detail_uid", productOperationDetail.getDetailUid());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getProductUid())) && productOperationDetail.getProductUid() != null) {
            queryWrapper.eq("product_uid", productOperationDetail.getProductUid());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getProductName())) && productOperationDetail.getProductName() != null) {
            queryWrapper.eq("product_name", productOperationDetail.getProductName());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getProductUrl())) && productOperationDetail.getProductUrl() != null) {
            queryWrapper.eq("product_url", productOperationDetail.getProductUrl());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getOptType())) && productOperationDetail.getOptType() != null) {
            queryWrapper.eq("opt_type", productOperationDetail.getOptType());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getObjNumber())) && productOperationDetail.getObjNumber() != null) {
            queryWrapper.eq("obj_number", productOperationDetail.getObjNumber());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getMemberUid())) && productOperationDetail.getMemberUid() != null) {
            queryWrapper.eq("member_uid", productOperationDetail.getMemberUid());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getMemberNickName())) && productOperationDetail.getMemberNickName() != null) {
            queryWrapper.eq("member_nick_name", productOperationDetail.getMemberNickName());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getMemberHeadImg())) && productOperationDetail.getMemberHeadImg() != null) {
            queryWrapper.eq("member_head_img", productOperationDetail.getMemberHeadImg());
        }
        if (StringUtils.isNotEmpty(String.valueOf(productOperationDetail.getPlatformUid())) && productOperationDetail.getPlatformUid() != null) {
            queryWrapper.eq("platform_uid", productOperationDetail.getPlatformUid());
        }
        return centreProductOperationDetailMapper.selectList(queryWrapper);
    }

    /**
     * 新增用户行为日志
     *
     * @param productOperationDetail 用户行为日志
     * @return 结果
     */
    @Override
    public boolean insertProductOperationDetail(ProductOperationDetail productOperationDetail) {

        return this.save(productOperationDetail);

    }

    /**
     * 修改用户行为日志
     *
     * @param productOperationDetail 用户行为日志
     * @return 结果
     */
    @Override
    public boolean updateProductOperationDetail(ProductOperationDetail productOperationDetail) {

        return this.updateById(productOperationDetail);
    }

    /**
     * 批量删除用户行为日志
     *
     * @param detailUids 需要删除的用户行为日志ID
     * @return 结果
     */
    @Override
    public boolean deleteProductOperationDetailByIds(Long[] detailUids) {
        return this.removeByIds(Arrays.asList(detailUids));
    }


}
